# placebo tests of theoretically unplausible outcomes


### RDDs ###
rd_clim1 <- RDestimate(testii1 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_clim1)
rd_clim2 <- RDestimate(testii2 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_clim2)
rd_clim3 <- RDestimate(testii3 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_clim3)
rd_clim4 <- RDestimate(testii4 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_clim4)
rd_clim5 <- RDestimate(testii5 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_clim5)
rd_clim6 <- RDestimate(testii6 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_clim6)
rd_clim7 <- RDestimate(testii7 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_clim7)
rd_clim8 <- RDestimate(testii8 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_clim8)
rd_clim9 <- RDestimate(testii9 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_clim9)


rd_cov1 <- RDestimate(secgrdec ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov1)
rd_cov2 <- RDestimate(scidecpb ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov2)
rd_cov3 <- RDestimate(admc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov3)
rd_cov4 <- RDestimate(panpriph ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov4)
rd_cov5 <- RDestimate(panmonpb ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov5)
rd_cov6 <- RDestimate(govpriph ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov6)
rd_cov7 <- RDestimate(govmonpb ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov7)
rd_cov8 <- RDestimate(panfolru ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov8)
rd_cov9 <- RDestimate(panclobo ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov9)
rd_cov10 <- RDestimate(panresmo ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov10)
rd_cov11 <- RDestimate(gvhanc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov11)
rd_cov12 <- RDestimate(gvjobc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov12)
rd_cov13 <- RDestimate(gveldc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov13)
rd_cov14 <- RDestimate(gvfamc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov14)
rd_cov15 <- RDestimate(hscopc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov15)
rd_cov16 <- RDestimate(gvbalc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov16)
rd_cov17 <- RDestimate(gvimpc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov17)
rd_cov18 <- RDestimate(gvconc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov18)
rd_cov19 <- RDestimate(respc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov19)
rd_cov20 <- RDestimate(reshhc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov20)
rd_cov21 <- RDestimate(hapljc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov21)
rd_cov22 <- RDestimate(hapirc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov22)
rd_cov23 <- RDestimate(hapwrc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov23)
rd_cov24 <- RDestimate(hapfuc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov24)
rd_cov25 <- RDestimate(hapfoc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov25)
rd_cov26 <- RDestimate(hapnoc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov26)
rd_cov27 <- RDestimate(hapnwc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov27)
rd_cov28 <- RDestimate(hapnpc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov28)
rd_cov29 <- RDestimate(haprec19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov29)
rd_cov30 <- RDestimate(hapdkc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov30)
rd_cov31 <- RDestimate(hapnac19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov31)
rd_cov32 <- RDestimate(icvacc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov32)
rd_cov33 <- RDestimate(getavc19 ~ date | cntry, data = ESS10, cutpoint = 0, bw = 14)
summary(rd_cov33)

### saving p-values ###
cl1 <- rd_clim1$p[1]
cl2 <- rd_clim2$p[1]
cl3 <- rd_clim3$p[1]
cl4 <- rd_clim4$p[1]
cl5 <- rd_clim5$p[1]
cl6 <- rd_clim6$p[1]
cl7 <- rd_clim7$p[1]
cl8 <- rd_clim8$p[1]
cl9 <- rd_clim9$p[1]

co1 <- rd_cov1$p[1]
co2 <- rd_cov2$p[1]
co3 <- rd_cov3$p[1]
co4 <- rd_cov4$p[1]
co5 <- rd_cov5$p[1]
co6 <- rd_cov6$p[1]
co7 <- rd_cov7$p[1]
co8 <- rd_cov8$p[1]
co9 <- rd_cov9$p[1]
co10 <- rd_cov10$p[1]
co11 <- rd_cov11$p[1]
co12 <- rd_cov12$p[1]
co13 <- rd_cov13$p[1]
co14 <- rd_cov14$p[1]
co15 <- rd_cov15$p[1]
co16 <- rd_cov16$p[1]
co17 <- rd_cov17$p[1]
co18 <- rd_cov18$p[1]
co19 <- rd_cov19$p[1]
co20 <- rd_cov20$p[1]
co21 <- rd_cov21$p[1]
co22 <- rd_cov22$p[1]
co23 <- rd_cov23$p[1]
co24 <- rd_cov24$p[1]
co25 <- rd_cov25$p[1]
co26 <- rd_cov26$p[1]
co27 <- rd_cov27$p[1]
co28 <- rd_cov28$p[1]
co29 <- rd_cov29$p[1]
co30 <- rd_cov30$p[1]
co31 <- rd_cov31$p[1]
co32 <- rd_cov32$p[1]
co33 <- rd_cov33$p[1]


### new dataset of p values ###
plac <- c(cl1,cl2,cl3,cl4,cl5,cl6,cl7,cl8,cl9,co1,
          co2,co3,co4,co5,co6,co7,co8,co9,co10,co11,co12,co13,co14,
          co15,co16,co17,co18,co19,co20,co21,co22,co23,co24,co25,
          co26,co27,co28,co29,co30,co31,co32,co33)

plac <- as.data.frame(plac)



### plot p values in comparison to uniform distribution ### 
theme_base2 <- 
  theme_minimal(base_size=20)  + 
  theme(legend.position=c(0.15, .9),  legend.key.size = unit(1,"line"),
        axis.text=element_text(size=20),axis.title.x=element_text(size=20),axis.title.y=element_text(size=20),
        plot.title = element_text(size=20, hjust= 0.5))


ggplot(plac, aes(sample = plac)) + 
  stat_qq(distribution = stats::qunif) +  
  geom_abline(linetype = "dashed", size = 1.2) + 
  geom_point(stat="qq", distribution = stats::qunif, size= 5) +
  geom_vline(xintercept = 0.05, linetype = "dashed", color = "red3", size = 1.2) + 
  geom_vline(xintercept = 0.1, linetype = "dashed", color = "blue", size = 1.2) +
  geom_hline(yintercept = 0.05, linetype = "dashed", color = "red3", size = 1.2) + 
  geom_hline(yintercept = 0.1, linetype = "dashed", color = "blue", size = 1.2) +   
  theme_base2 + ylab("p-values") + 
  xlab("Uniform Distribution") +
  ylim(0,1) +
  xlim(0,1)
